package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.service.AdminLumiereCouponService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumiereCoupon;
import org.springframework.web.bind.annotation.*;
@Api(tags = "新优惠券API")
@RestController
@RequestMapping("admin/coupon1")
@RequiredArgsConstructor
public class AdminLumiereCouponController extends ResponseUtil {

    private final AdminLumiereCouponService adminLumiereCouponService;

    @ApiOperation("优惠券列表-「电子、实体、推广」")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit",value = "数量"),
            @ApiImplicitParam(name = "page",value = "当前页"),
            @ApiImplicitParam(name = "status",value = "状态"),
            @ApiImplicitParam(name = "name",value = "优惠券名称")
    })
    @LogAnno
    @GetMapping("/coupons")
    public Response coupons(@RequestParam("limit")Integer limit,
                            @RequestParam("page")Integer page,
                            @RequestParam("status")Integer status,
                            @RequestParam("name")String name){
        return adminLumiereCouponService.coupons(limit,page,status,name);
    }

    @ApiOperation("优惠券-「创建优惠券」")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "优惠券"),
            @ApiImplicitParam(name = "status",value = "状态"),
            @ApiImplicitParam(name = "picture_url",value = "图片"),
            @ApiImplicitParam(name = "descr",value = "描述")
    })
    @PostMapping("/add")
    @LogAnno
    public Response addCoupon(@RequestBody LumiereCoupon coupon){
        return adminLumiereCouponService.addConpon(coupon);
    }

    @ApiOperation("优惠券-「获取一个」")
    @ApiImplicitParam(name = "id",value = "ID")
    @LogAnno
    @GetMapping("/find")
    public Response findCoupon(@RequestParam("id")Long id){
        return adminLumiereCouponService.findConpon(id);
    }

    @ApiOperation("优惠券-「删除」")
    @ApiImplicitParam(name = "id",value = "ID")
    @LogAnno
    @GetMapping("/remove")
    public Response removeCoupon(@RequestParam("id")Long id){
        return adminLumiereCouponService.removeConpon(id);
    }

    @ApiOperation("优惠券—「编辑」")
    @LogAnno
    @PostMapping("/edit")
    public Response editCoupon(@RequestBody LumiereCoupon coupon){
        return adminLumiereCouponService.editConpon(coupon);
    }

    @ApiOperation("优惠券-「上下架」")
    @LogAnno
    @PostMapping("/status")
    public Response statusCoupon(@RequestBody LumiereCoupon coupon){
        return adminLumiereCouponService.statusCoupon(coupon);
    }


    //
    @ApiOperation("优惠券-「选项」")
    @LogAnno
    @GetMapping("/option")
    public Response couponOption(){
        return adminLumiereCouponService.couponOption();
    }


}
